package com.chance.cc.crawler.development.command.trigger.domain.douyin.api;

import com.chance.cc.crawler.core.CrawlerJob;
import com.chance.cc.crawler.core.downloader.HttpPage;
import com.chance.cc.crawler.development.command.job.domain.douyin.api.*;
import com.chance.cc.crawler.development.command.job.domain.douyin.api.custom.DYAccountCustomCrawlerScheduleJob;
import com.chance.cc.crawler.development.command.job.domain.douyin.api.custom.DYAccountSupplementCrawlerScheduleJob;
import com.chance.cc.crawler.development.command.job.domain.douyin.api.custom.DYCommentCustomCrawlerScheduleJob;
import com.chance.cc.crawler.development.command.job.domain.douyin.api.custom.DYSearchCustomCrawlerScheduleJob;
import com.chance.cc.crawler.development.command.trigger.CrawlerJobTriggerCommand;
import com.chance.cc.crawler.meta.core.bean.CrawlerMetaConstant;

import static com.chance.cc.crawler.development.command.publish.douyin.DYPublishCrawlerJob.metaServerIP;
import static com.chance.cc.crawler.development.command.publish.douyin.DYPublishCrawlerJob.metaServerPort;

/**
 * @author bx
 * @date 2020/12/7 0007 11:15
 */
public class DYCrawlerScheduleTrigger {

    private static String domainId = "api-dy";

    private static CrawlerJobTriggerCommand crawlerJobTriggerCommand =
            new CrawlerJobTriggerCommand(metaServerIP,metaServerPort);

    public static void main(String[] args) {
//        publishDYAccountSimpleScheduleTriggerInfo();
//        publishDYSearchSimpleScheduleTriggerInfo();

        publishDYAccountScheduleTriggerInfo();
//        publishDYSearchScheduleTriggerInfo();

//        publishDYSearchZDScheduleTriggerInfo();

//        publishDYCommentScheduleTriggerInfo();
//
//        publishDYAccountSupplementScheduleTriggerInfo();
//
//        publishDYAccountCustomScheduleTriggerInfo();
//
//        publishDYCommentCustomScheduleTriggerInfo();
//
//        publishDYSearchCustomScheduleTriggerInfo();

//        publishDYDevicesRegisterScheduleTriggerInfo();
    }
    public static void publishDYAccountScheduleTriggerInfo(){
        CrawlerJob crawlerJob = DYAccountCrawlerScheduleJob.dyCrawlerSchduler();
        HttpPage page = crawlerJobTriggerCommand.addOrUpdateScheduleCrawlerTrigger(
                crawlerJob.generateCrawlerKey(),
                crawlerJob.generateCrawlerTriggerKey(),
                domainId,
                CrawlerMetaConstant.ScheduleJobTrigger_Cron,
                "0 20 0 * * ?",
                "抖音账户采集任务，每天0：20执行");
        System.out.println("添加采集调度： "+page.getRawText());
    }

    public static void publishDYAccountSimpleScheduleTriggerInfo(){
        CrawlerJob crawlerJob = DYAccountCrawlerScheduleJob.dyCrawlerSchduler();
        HttpPage page = crawlerJobTriggerCommand.addOrUpdateScheduleCrawlerTrigger(
                crawlerJob.generateCrawlerKey(),
                crawlerJob.generateCrawlerTriggerKey(),
                domainId,
                CrawlerMetaConstant.ScheduleJobTrigger_Simple,
                "",
                "抖音账户实时采集任务，临时执行");
        System.out.println("添加采集调度： "+page.getRawText());
    }

    public static void publishDYSearchScheduleTriggerInfo(){
        CrawlerJob crawlerJob = DYSearchCrawlerScheduleJob.dyCrawlerSchduler();
        HttpPage page = crawlerJobTriggerCommand.addOrUpdateScheduleCrawlerTrigger(
                crawlerJob.generateCrawlerKey(),
                crawlerJob.generateCrawlerTriggerKey(),
                domainId,
                CrawlerMetaConstant.ScheduleJobTrigger_Cron,
                "0 20 2 * * ?",
                "抖音关键词采集任务，每天2：20执行");
        System.out.println("添加采集调度： "+page.getRawText());
    }

    public static void publishDYSearchSimpleScheduleTriggerInfo(){
        CrawlerJob crawlerJob = DYSearchCrawlerScheduleJob.dyCrawlerSchduler();
        HttpPage page = crawlerJobTriggerCommand.addOrUpdateScheduleCrawlerTrigger(
                crawlerJob.generateCrawlerKey(),
                crawlerJob.generateCrawlerTriggerKey(),
                domainId,
                CrawlerMetaConstant.ScheduleJobTrigger_Simple,
                "",
                "抖音关键词日常采集任务，临时启动");
        System.out.println("添加采集调度： "+page.getRawText());
    }

    public static void publishDYSearchZDScheduleTriggerInfo(){
        CrawlerJob crawlerJob = DYSearchZDCrawlerScheduleJob.dyCrawlerSchduler();
        HttpPage page = crawlerJobTriggerCommand.addOrUpdateScheduleCrawlerTrigger(
                crawlerJob.generateCrawlerKey(),
                crawlerJob.generateCrawlerTriggerKey(),
                domainId,
                CrawlerMetaConstant.ScheduleJobTrigger_Cron,
                "0 20 12 ? * WED",
                "抖音关键词周度采集任务，每周12：20执行");
        System.out.println("添加采集调度： "+page.getRawText());
    }

    public static void publishDYCommentScheduleTriggerInfo(){
        CrawlerJob crawlerJob = DYCommentCrawlerScheduleJob.dyCrawlerSchduler();
        HttpPage page = crawlerJobTriggerCommand.addOrUpdateScheduleCrawlerTrigger(
                crawlerJob.generateCrawlerKey(),
                crawlerJob.generateCrawlerTriggerKey(),
                domainId,
                CrawlerMetaConstant.ScheduleJobTrigger_Simple,
                "",
                "抖音评论采集任务");
        System.out.println("添加采集调度： "+page.getRawText());
    }

    public static void publishDYAccountSupplementScheduleTriggerInfo(){
        CrawlerJob crawlerJob = DYAccountSupplementCrawlerScheduleJob.dyCrawlerSchduler();
        HttpPage page = crawlerJobTriggerCommand.addOrUpdateScheduleCrawlerTrigger(
                crawlerJob.generateCrawlerKey(),
                crawlerJob.generateCrawlerTriggerKey(),
                domainId,
                CrawlerMetaConstant.ScheduleJobTrigger_Simple,
                "",
                "抖音账户补采采集任务");
        System.out.println("添加采集调度： "+page.getRawText());
    }

    public static void publishDYAccountCustomScheduleTriggerInfo(){
        CrawlerJob crawlerJob = DYAccountCustomCrawlerScheduleJob.dyCrawlerSchduler();
        HttpPage page = crawlerJobTriggerCommand.addOrUpdateScheduleCrawlerTrigger(
                crawlerJob.generateCrawlerKey(),
                crawlerJob.generateCrawlerTriggerKey(),
                domainId,
                CrawlerMetaConstant.ScheduleJobTrigger_Simple,
                "",
                "抖音账户自定义采集任务");
        System.out.println("添加采集调度： "+page.getRawText());
    }

    public static void publishDYCommentCustomScheduleTriggerInfo(){
        CrawlerJob crawlerJob = DYCommentCustomCrawlerScheduleJob.dyCrawlerSchduler();
        HttpPage page = crawlerJobTriggerCommand.addOrUpdateScheduleCrawlerTrigger(
                crawlerJob.generateCrawlerKey(),
                crawlerJob.generateCrawlerTriggerKey(),
                domainId,
                CrawlerMetaConstant.ScheduleJobTrigger_Simple,
                "",
                "抖音评论自定义采集任务");
        System.out.println("添加采集调度： "+page.getRawText());
    }

    public static void publishDYSearchCustomScheduleTriggerInfo(){
        CrawlerJob crawlerJob = DYSearchCustomCrawlerScheduleJob.dyCrawlerSchduler();
        HttpPage page = crawlerJobTriggerCommand.addOrUpdateScheduleCrawlerTrigger(
                crawlerJob.generateCrawlerKey(),
                crawlerJob.generateCrawlerTriggerKey(),
                domainId,
                CrawlerMetaConstant.ScheduleJobTrigger_Simple,
                "",
                "抖音自定义关键词搜索采集任务");
        System.out.println("添加采集调度： "+page.getRawText());
    }

    public static void publishDYDevicesRegisterScheduleTriggerInfo(){
        CrawlerJob crawlerJob = DYDevicesRegisterScheduleJob.dyCrawlerSchduler();
        HttpPage page = crawlerJobTriggerCommand.addOrUpdateScheduleCrawlerTrigger(
                crawlerJob.generateCrawlerKey(),
                crawlerJob.generateCrawlerTriggerKey(),
                domainId,
                CrawlerMetaConstant.ScheduleJobTrigger_Simple,
                "",
                "抖音设备注册任务");
        System.out.println("添加采集调度： "+page.getRawText());
    }
}
